from ctypes import windll, byref
from ctypes.wintypes import DWORD

flags = DWORD()
conexion = windll.winInet.InternetGetConnectedState(byref(flags), None)

print flags.value
if (conexion == 1):
    connect_state = True
else:
    connect_state = False
flags_tmp = flags.value    
INTERNET_CONNECTION_MODEM = 1
INTERNET_CONNECTION_LAN = 2
INTERNET_CONNECTION_PROXY = 4
INTERNET_CONNECTION_MODEM_BUSY = 8

netStates = ""
if ((flags_tmp & INTERNET_CONNECTION_MODEM) != 0):
    netStates += " Connect by MODEM\n"
if ((flags_tmp & INTERNET_CONNECTION_LAN) != 0):
    netStates += "Connect by LAN\n"
if ((flags_tmp & INTERNET_CONNECTION_PROXY) != 0):
    netStates += "Connect by PROXY\n"
if ((flags_tmp & INTERNET_CONNECTION_MODEM_BUSY) != 0):
    netStates += " MODEM is busy\n"

print "connect_state:" + str(connect_state)
print netStates